package com.maxd.respository;

import com.maxd.model.OrderPartnerInfo;
import com.maxd.model.Orders;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface OrderPartnerInfoRepository extends JpaRepository<OrderPartnerInfo, Long>, JpaSpecificationExecutor<OrderPartnerInfo> {
    @Transactional
    @Modifying
    @Query("update OrderPartnerInfo p set p.status = ?2 where p.orderId = ?1")
    Integer updateStatus(String orderId, String status);

    @Query(value = "from OrderPartnerInfo o where o.orderId =:orderId")
    OrderPartnerInfo queryByOrderId(@Param("orderId") String orderId);
}